1. Field of the Invention
The invention relates in general to a memory access method, and more particularly to a method for accessing data from a non-volatile memory in a south bridge.
2. Description of the Related Art
For a unified memory architecture (UMA), the VGA software of a computer system needs to call a call-back function when accessing data (such as frame buffer size) from a non-volatile memory (such as a CMOS memory) of a south bridge. Then, the call-back function accesses necessary information from the memory and transmits the information to the VGA software.
However, if an interrupt occurs while the call-back function is accessing the memory, the interrupt handler may accidentally alter the address of the desired memory. If the interrupt handler alters the desired address of the memory, after the interrupt finishes, the call-back function may access data from erroneous address of the memory and result in unexpected results.
FIG. 1 is a flowchart illustrating the occurrence of error in a conventional memory access method. In step 110, an address value is transmitted to an index port (such as 70h port) of the south bridge, and the data is accessed from the address of the memory corresponding to the address value. In step 120, an interrupt occurs. Afterwards, in step 130, the interrupt handler of the interrupt accidentally alters the address value corresponding to the index port as an erroneous address value. In step 140, when the memory is accessed via a data port (such as 71h) of the south bridge according to the address value of the index port, the access is based on an erroneous address value altered by the interrupt handler rather than on the original address value. Therefore, data is accessed from erroneous address of the memory corresponding to the erroneous address value memory, hence resulting in unexpected results.
FIG. 2 is an example corresponding to the error of FIG. 1. The blocks 210, 220 and 230 respectively are the instructions of the VGA software, the call-back function and the interrupt handler. In block 210, the VGA software calls a call-back function. Afterwards, the method proceeds to block 220, the call-back function transmits the address value A0h to an index port 70h of the south bridge. Afterwards, an interrupt occurs. In block 230, the interrupt handler of the interrupt accidentally alters the address value A0h corresponding to the index port 70h as an erroneous address value 0ch. When the interrupt finishes, the method returns to block 220, the call-back function accesses data from the memory via the data port 71h of the south bridge according to the address value of the index port 70h, and the access is based on an erroneous address value 0ch altered by the interrupt handler rather than on the original address value A0h. Therefore, data is accessed from erroneous address 0ch of the memory, not from the desired address A0h.